package kosta.model.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import kosta.model.vo.AuctionVO;
import kosta.model.vo.BidVO;
import kosta.model.vo.BigClassVO;
import kosta.model.vo.DeleteConfirmVO;
import kosta.model.vo.MemberVO;
import kosta.model.vo.SearchVO;
import kosta.model.vo.SmallClassVO;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AuctionDAOImpl implements AuctionDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public List<AuctionVO> getMainAuctionList() {	
		return sqlSessionTemplate.selectList("auction.getMainAuctionList");
	}

	@Override
	public AuctionVO findAuctionInfo(int boardNo) {
		return sqlSessionTemplate.selectOne("auction.findAuctionInfo",boardNo);
	}

	@Override
	public MemberVO findMemberInfo(int memberNo) {
		return sqlSessionTemplate.selectOne("auction.findMemberInfo",memberNo);
	}

	@Override
	public BigClassVO findBigClass(int bigNo) {
		return sqlSessionTemplate.selectOne("auction.findBigClass",bigNo);
	}

	@Override
	public SmallClassVO findSmallClass(int boardNo) {
		return sqlSessionTemplate.selectOne("auction.findSmallClass",boardNo);
	}



	//대분류 받아오는 메소드
	@Override
	public List<BigClassVO> getBigClassList() {
		return sqlSessionTemplate.selectList("auction.getBigClassList");
	}

	@Override
	public List<SmallClassVO> getSmallClassList(int bigClass) {
		return sqlSessionTemplate.selectList("auction.getSmallClassList",bigClass);
	}

	@Override
	public List<AuctionVO> getAuctionList(SearchVO svo) {
		return sqlSessionTemplate.selectList("auction.getAllAuctionList",svo);
	}

	@Override
	public int getTotalPostingCount(SearchVO svo) {		
		return sqlSessionTemplate.selectOne("auction.getTotalPostingCount",svo);
	}

	@Override
	public AuctionVO showContent(int boardNo) {
		// TODO Auto-generated method stub
		return null;
	}

	public void bidRegister(BidVO bvo){
		sqlSessionTemplate.insert("auction.bidRegister",bvo);
	}
	
	public List<BidVO> bid(int boardNo){
		return sqlSessionTemplate.selectList("auction.bid",boardNo);
	}

	public String priceCheck(BidVO bvo){
		return sqlSessionTemplate.selectOne("auction.priceCheck",bvo);
	}


	@Override
	public void auctionRegister(AuctionVO avo) {
			sqlSessionTemplate.insert("auction.auctionRegister",avo);
		
	}


	@Override
	public void updateHits(int boardNo) {
		sqlSessionTemplate.update("auction.updateHits",boardNo);
	}
	public void endBid(AuctionVO avo){
		sqlSessionTemplate.update("auction.endbid",avo);
	}

	public int minbidPrice(int boardNo){
		return sqlSessionTemplate.selectOne("auction.minbidPrice",boardNo);
	}
	public void deleteConfirm(DeleteConfirmVO dcvo){
		sqlSessionTemplate.insert("auction.deleteConfirm",dcvo);
	}
	
	@Override
    public void auctionUpdate(AuctionVO avo) {
	      sqlSessionTemplate.update("auction.auctionUpdate",avo);
	}
	@Override
	public DeleteConfirmVO findDelConfirm(int boardNo){
		return sqlSessionTemplate.selectOne("auction.findDelConfirm",boardNo);
	}

	
}
